const Service = require('egg').Service;

class MenuService extends Service {
  async getMenu(rid) {
    let menuList;
    rid = parseInt(rid);
    // 菜单功能暂使用固定数据
    switch (rid) {
      case 1: menuList = [
        {
          id: 1,
          authName: "商品管理",
          path: null,
          children: [
            {
              id: 101,
              authName: "商品列表",
              path: '/goods'
            }
          ]
        },
        {
          id: 2,
          authName: "订单管理",
          path: null,
          children: [
            {
              id: 201,
              authName: "商品订单",
              path: '/order'
            }
          ]
        },
        {
          id: 3,
          authName: "用户管理",
          path: null,
          children: [
            {
              id: 301,
              authName: "用户列表",
              path: '/user'
            }
          ]
        },
        {
          id: 4,
          authName: "权限管理",
          path: null,
          children: [
            {
              id: 401,
              authName: "角色列表",
              path: '/role'
            },
            {
              id: 402,
              authName: "权限列表",
              path: '/limit'
            },
          ]
        }
      ]; break;
      case 2: menuList = [
        {
          id: 1,
          authName: "商品管理",
          path: null,
          children: [
            {
              id: 101,
              authName: "商品列表",
              path: '/goods'
            }
          ]
        }
      ]; break;
      case 3: menuList = [
        {
          id: 2,
          authName: "订单管理",
          path: null,
          children: [
            {
              id: 201,
              authName: "商品订单",
              path: '/order'
            }
          ]
        }
      ]; break;
      default: menuList = null; break;
    }
    return menuList;
  }
}

module.exports = MenuService;
